import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        name: 'Index',
        redirect: '/home', // 重定向:重新指向其它path,会改变网址
    }, {
        path: '/home',
        name: 'Home',
        component: Home,
        meta: {
            title: '首页'
        }
    },
    {
        path: '/create',
        name: 'Create',
        component: () =>
            import ( /* webpackChunkName: "about" */ '../views/Create.vue'),
        meta: {
            title: '创作'
        },
        children: [{
            path: 'hot',
            name: 'Hot',
            component: () =>
                import ( /* webpackChunkName: "about" */ '../views/create/Hot.vue'),
            meta: {
                title: '近期热点'
            },
        }, {
            path: 'potential',
            name: 'Potential',
            component: () =>
                import ( /* webpackChunkName: "about" */ '../views/create/Potential.vue'),
            meta: {
                title: '潜力问题'
            },
        }, {
            path: 'featured',
            name: 'Featured',
            component: () =>
                import ( /* webpackChunkName: "about" */ '../views/create/Featured.vue'),
            meta: {
                title: '问题推荐'
            },
        }]
    }, {
        path: '/manage',
        name: 'Manage',
        component: () =>
            import ( /* webpackChunkName: "about" */ '../views/Manage.vue'),
        meta: {
            title: '管理'
        },
        children: [{
            path: 'article',
            name: 'Article',
            component: () =>
                import ( /* webpackChunkName: "about" */ '../views/manage/Article.vue'),
            meta: {
                title: '内容管理'
            },
        }, {
            path: 'comment',
            name: 'Comment',
            component: () =>
                import ( /* webpackChunkName: "about" */ '../views/manage/Comment.vue'),
            meta: {
                title: '评论管理'
            },
        }]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router